using UnityEngine;
using UnityEngine.UI;

public class AltarTip : BasePanel
{
    //按钮
    public Button closeButton;
    public Button okButton;
    public override void OnClose()
    {
        base.OnClose();
        GameManager.Instance.canOprate=true;
    }
    public override void OnInit()
    {
        base.OnInit();

        path="UI/OtherTip/AltarTip";
        type=PanelType.Tip;

        GameManager.Instance.canOprate=false;
    }
    public override void OnShow(params object[] par)
    {
        base.OnShow(par);

        closeButton=item.transform.Find("Close").GetComponent<Button>();
        okButton=item.transform.Find("Ok").GetComponent<Button>();

        closeButton.onClick.AddListener(CloseButton);
        okButton.onClick.AddListener(OkButton);
    }
    //关闭
    public void CloseButton()
    {
        Close();

        AudManager.instance.PlayUIAud(AudManager.instance.uiDic["点击"], 1f);
    }
    public void OkButton()
    {
        //查看是否有超脱石
        if(GameManager.Instance.stoneNum>0)
        {
            TipSayManager.Instance.Say("<color=red> 这个祭坛已经不能用了 </color>");
        }
        else
        {
            if(GameManager.Instance.keyNum>0)
            {
                GameManager.Instance.ChangeKey(-1);
                GameManager.Instance.ChangeStone(1);
                TipSayManager.Instance.Say("你获得了<color=yellow> 超脱石 </color>");
                TipSayManager.Instance.Say("你感受到了某个存在的<color=red> 注视 </color>");
            }
            else
            {
                TipSayManager.Instance.Say("献祭<color=red> 失败 </color>");
            }
        }

        CloseButton();
    }
}
